

cc.Class({
    extends: cc.Component,

    properties: {
        platformPre: cc.Prefab,
        groundNode: cc.Node,
    },



    onLoad() {
        this.createPlatform();
        this.schedule(this.createPlatform, 4);
    },

    start() {

    },

    // update (dt) {},
    createPlatform() {
        let platformNode = cc.instantiate(this.platformPre);
        platformNode.parent = this.node;
        let maxHeight = - this.groundNode.height * 0.5;
        let minHeight = -cc.winSize.height / 2 + this.groundNode.height * 1.5;
        let height = Math.random() * (maxHeight - minHeight) + minHeight;
        platformNode.y = height;
        platformNode.x = cc.winSize.width / 2 + platformNode.width / 2;
    }

});
